package com.kaichaohulian.baocms.adapter;

import android.content.Intent;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kaichaohulian.baocms.R;
import com.kaichaohulian.baocms.activity.HelpSongActivity;
import com.kaichaohulian.baocms.activity.OtherXuQiuActivity;
import com.kaichaohulian.baocms.newmodel.PlatFormModel;

import java.util.List;

/**
 * Created by gaoyuan on 2017/5/4.
 */

public class PlatFormAdapter extends BaseQuickAdapter<PlatFormModel.DataObjectBean, BaseViewHolder> {

    View platform_jump;

    public PlatFormAdapter(List<PlatFormModel.DataObjectBean> data) {
        super(R.layout.item_platform, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final PlatFormModel.DataObjectBean item) {

//        fu  发布服务
        platform_jump = helper.getView(R.id.platform_jump);
        if (item.getType().equals("1")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.mai);
        } else if (item.getType().equals("2")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.qu);
        } else if (item.getType().equals("3")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.song);
        }
        if (item.getType().equals("4")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.fu);
        } else if (item.getType().equals("5")) {
//         排队   pai
            helper.setImageResource(R.id.img_purchase, R.mipmap.pai);
        } else if (item.getType().equals("6")) {
            //其他需求
            helper.setImageResource(R.id.img_purchase, R.mipmap.xu);
        } else if (item.getType().equals("7")) {
            //顺
            helper.setImageResource(R.id.img_purchase, R.mipmap.shun);

        } else if (item.getType().equals("8")) {
            //代
            helper.setImageResource(R.id.img_purchase, R.mipmap.dai);

        } else if (item.getType().equals("9")) {
//预
            helper.setImageResource(R.id.img_purchase, R.mipmap.yu);
        } else if (item.getType().equals("10")) {
            //共
            helper.setImageResource(R.id.img_purchase, R.mipmap.gong);

        } else {

        }


        helper.setText(R.id.text_title, item.getTitle());
        helper.setText(R.id.text_time, item.getCreatedTime());
        helper.setText(R.id.text_money,item.getReward());

        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent();
                intent.putExtra("fabuid", item.getUserId());
                if (item.getType().equals("4")) {
//其他服务
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
//                    intent.setClass(mContext, OtherXuQiuActivity.class);
                    intent.setClass(mContext, HelpSongActivity.class);
                } else if (item.getType().equals("3")) {
//帮我送
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, HelpSongActivity.class);
                } else if (item.getType().equals("1")) {
//帮我买
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, HelpSongActivity.class);
                } else if (item.getType().equals("2")) {
//帮我取
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, HelpSongActivity.class);
                } else if (item.getType().equals("6")) {
//其他服务
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, OtherXuQiuActivity.class);
                } else if (item.getType().equals("9")) {
//其他服务
                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, OtherXuQiuActivity.class);
                } else {

                    intent.putExtra("type", item.getType());
                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, OtherXuQiuActivity.class);
                }


                mContext.startActivity(intent);
          /*
               Intent intent = new Intent();

                if (item.getType().equals("6")){

                    intent.putExtra("demandId", item.getId());
                    intent.setClass(mContext, OtherXuQiuActivity.class);
                }



                mContext.startActivity(intent);*/
            }
        });
    }

}
